#include<stdio.h>

/*第十四课：学习三元运算符*/

int main()
{
    int a = 10;
    int b = 20;
    int c = a > b ? a : b;
    printf("c = %d\n", c);//满足条件，则返回a的值，并赋值给c

    //从X，Y，Z三个数中找出最大的数
    int X = 17;
    int Y = 22;
    int Z = 9;
    int result = X > Y ? (X > Z ? X : Z) : (Y > Z ? Y : Z);
    printf("result = %d\n", result);

    //取绝对值
    int num = -10;
    num = num > 0 ? num : -num;
    printf("%d\n", num);

    return 0;
}